<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page language="java" import="java.util.*" %>
<jsp:useBean id="pageBean" scope="request" class="com.agileai.hotweb.domain.PageBean"/>
<%
String currentSubTableId = pageBean.getStringValue("currentSubTableId");
String currentSubTableIndex = pageBean.getStringValue("currentSubTableIndex");
%>
<%@ taglib uri="http://www.ecside.org" prefix="ec"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>陌生拜访</title>
<%@include file="/jsp/inc/resource.inc.jsp"%>
<script language="javascript">
function saveMasterRecord(){
	if (validate()){
		if (ele("currentSubTableId")){
			var subTableId = $("#currentSubTableId").val();
			if (!checkEntryRecords(subTableId)){
				return;
			}
		}
		showSplash();
		postRequest('form1',{actionType:'saveMasterRecord',onComplete:function(responseText){
			if ("fail" != responseText){
				$('#operaType').val('update');
				$('#TASK_ID').val(responseText);
				doSubmit({actionType:'prepareDisplay'});
			}else{
				hideSplash();
				writeErrorMsg('保存操作出错啦！');
			}
		}});
	}
}
function changeSubTable(subTableId){
	$('#currentSubTableId').val(subTableId);
	doSubmit({actionType:'changeSubTable'});
}
function refreshPage(){
	doSubmit({actionType:'changeSubTable'});
}
function addEntryRecord(subTableId){
	$('#currentSubTableId').val(subTableId);
	doSubmit({actionType:'addEntryRecord'});
}
function deleteEntryRecord(subTableId){
	if (!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;
	}
	if (confirm('确认要删除该条记录吗？')){
		$('#currentSubTableId').val(subTableId);
		doSubmit({actionType:'deleteEntryRecord'});	
	}
}
function checkEntryRecords(subTableId){
	var result = true;
	var currentRecordSize = $('#currentRecordSize').val();
	return result;
}
var insertSubRecordBox;
function insertSubRecordRequest(title,handlerId){
	if (!insertSubRecordBox){
		insertSubRecordBox = new PopupBox('insertSubRecordBox',title,{size:'normal',height:'300px',top:'10px'});
	}
	var url = 'index?'+handlerId+'&operaType=insert&TASK_ID='+$('#TASK_ID').val();
	insertSubRecordBox.sendRequest(url);	
}
var copySubRecordBox;
function copySubRecordRequest(title,handlerId,subPKField){
	if (!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;
	}
	if (!copySubRecordBox){
		copySubRecordBox = new PopupBox('copySubRecordBox',title,{size:'normal',height:'300px',top:'10px'});
	}
	var url = 'index?'+handlerId+'&operaType=copy&'+subPKField+'='+$("#"+subPKField).val();
	copySubRecordBox.sendRequest(url);	
}
var viewSubRecordBox;
function viewSubRecordRequest(operaType,title,handlerId,subPKField){
	if (!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;
	}
	if (!viewSubRecordBox){
		viewSubRecordBox = new PopupBox('viewSubRecordBox',title,{size:'normal',height:'300px',top:'10px'});
	}
	var url = 'index?'+handlerId+'&operaType='+operaType+'&'+subPKField+'='+$("#"+subPKField).val();
	viewSubRecordBox.sendRequest(url);
}
function deleteSubRecord(){
	if (!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;
	}
	if (confirm('确认要删除该条记录吗？')){
		doSubmit({actionType:'deleteSubRecord'});	
	}
}
function doMoveUp(){
	if (!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;
	}
	doSubmit({actionType:'moveUp'});
}
function doMoveDown(){
	if (!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;
	}	
	doSubmit({actionType:'moveDown'});
}
</script>
</head>
<body>
<form action="<%=pageBean.getHandlerURL()%>" name="form1" id="form1" method="post">
<%@include file="/jsp/inc/message.inc.jsp"%>
<div style="padding-top:7px;">
<div id="__ParamBar__" style="float: right;">&nbsp;</div>
<div class="photobg1" id="tabHeader">
<div class="newarticle1" onclick="changeSubTable('_base')">基础信息</div>
<%if (!"insert".equals(pageBean.getOperaType())){%>
 <div class="newarticle1" onclick="changeSubTable('CrmOrgInfo')">CRM_ORG_INFO</div>
<%}%>
</div>
<div class="photobox newarticlebox" id="Layer0" style="height:auto;">
<div style="margin:2px;">
<div id="__ToolBar__">
<table border="0" cellpadding="0" cellspacing="1">
<tr>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onclick="enableSave()" ><input value="&nbsp;" type="button" class="editImgBtn" id="modifyImgBtn" title="编辑" />编辑</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onclick="saveMasterRecord();"><input value="&nbsp;" type="button" class="saveImgBtn" id="saveImgBtn" title="保存" />保存</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onclick="goToBack();"><input value="&nbsp;" type="button" class="backImgBtn" title="返回" />返回</td>
</tr>
</table>
</div>
<table class="detailTable" cellspacing="0" cellpadding="0">
<tr>
	<th width="100" nowrap>ORG_ID</th>
	<td><input id="ORG_ID" label="ORG_ID" name="ORG_ID" type="text" value="<%=pageBean.inputValue("ORG_ID")%>" size="24" class="text" />
</td>
</tr>
<tr>
	<th width="100" nowrap>CUST_ID</th>
	<td><input id="CUST_ID" label="CUST_ID" name="CUST_ID" type="text" value="<%=pageBean.inputValue("CUST_ID")%>" size="24" class="text" />
</td>
</tr>
<tr>
	<th width="100" nowrap>CRM_TC_ID</th>
	<td><input id="CRM_TC_ID" label="CRM_TC_ID" name="CRM_TC_ID" type="text" value="<%=pageBean.inputValue("CRM_TC_ID")%>" size="24" class="text" />
</td>
</tr>
<tr>
	<th width="100" nowrap>TASK_REVIEW_ID</th>
	<td><input id="TASK_REVIEW_ID" label="TASK_REVIEW_ID" name="TASK_REVIEW_ID" type="text" value="<%=pageBean.inputValue("TASK_REVIEW_ID")%>" size="24" class="text" />
</td>
</tr>
<tr>
	<th width="100" nowrap>SALE_ID</th>
	<td><input id="SALE_ID" label="SALE_ID" name="SALE_ID" type="text" value="<%=pageBean.inputValue("SALE_ID")%>" size="24" class="text" />
</td>
</tr>
<tr>
	<th width="100" nowrap>TASK_FOLLOW_STATE</th>
	<td><input id="TASK_FOLLOW_STATE" label="TASK_FOLLOW_STATE" name="TASK_FOLLOW_STATE" type="text" value="<%=pageBean.inputValue("TASK_FOLLOW_STATE")%>" size="24" class="text" />
</td>
</tr>
<tr>
	<th width="100" nowrap>TASK_CLASS</th>
	<td><input id="TASK_CLASS" label="TASK_CLASS" name="TASK_CLASS" type="text" value="<%=pageBean.inputValue("TASK_CLASS")%>" size="24" class="text" />
</td>
</tr>
<tr>
	<th width="100" nowrap>TASK_CREATE_TIME</th>
	<td><input id="TASK_CREATE_TIME" label="TASK_CREATE_TIME" name="TASK_CREATE_TIME" type="text" value="<%=pageBean.inputTime("TASK_CREATE_TIME")%>" size="24" class="text" /><img id="TASK_CREATE_TIMEPicker" src="images/calendar.gif" width="16" height="16" alt="日期/时间选择框" />
</td>
</tr>
<tr>
	<th width="100" nowrap>TASK_FINISH_TIME</th>
	<td><input id="TASK_FINISH_TIME" label="TASK_FINISH_TIME" name="TASK_FINISH_TIME" type="text" value="<%=pageBean.inputTime("TASK_FINISH_TIME")%>" size="24" class="text" /><img id="TASK_FINISH_TIMEPicker" src="images/calendar.gif" width="16" height="16" alt="日期/时间选择框" />
</td>
</tr>
<tr>
	<th width="100" nowrap>TASK_CUST_STATE</th>
	<td><input id="TASK_CUST_STATE" label="TASK_CUST_STATE" name="TASK_CUST_STATE" type="text" value="<%=pageBean.inputValue("TASK_CUST_STATE")%>" size="24" class="text" />
</td>
</tr>
</table>
</div>
</div>
<%if (!"insert".equals(pageBean.getOperaType())){%>
<%if ("CrmOrgInfo".equals(currentSubTableId)){ %>
<div class="photobox newarticlebox" id="Layer2" style="height:auto;">
<div id="__ToolBar__">
<table border="0" cellpadding="0" cellspacing="1">
<tr>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onclick="insertSubRecordRequest('CRM_ORG_INFO','CrmOrgInfoEditBox')"><input value="&nbsp;" title="新增" type="button" class="createImgBtn" />新增</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onclick="copySubRecordRequest('CRM_ORG_INFO','CrmOrgInfoEditBox','ORG_ID')"><input value="&nbsp;" title="复制" type="button" class="copyImgBtn" />复制</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onclick="viewSubRecordRequest('update','CRM_ORG_INFO','CrmOrgInfoEditBox','ORG_ID')"><input value="&nbsp;" title="编辑" type="button" class="editImgBtn" />编辑</td>      
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onclick="deleteSubRecord()"><input value="&nbsp;" title="删除" type="button" class="delImgBtn" />删除</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" onclick="doMoveUp()" class="bartdx" align="center"><input id="upImgBtn" value="&nbsp;" title="上移" type="button" class="upImgBtn" style="margin-right:0px;" />上移</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" onclick="doMoveDown()" class="bartdx" align="center"><input id="downImgBtn" value="&nbsp;" title="下移" type="button" class="downImgBtn" style="margin-right:0px;" />下移</td>           
</tr>   
   </table>
</div>
<div style="margin:2px;">
<%
List param1Records = (List)pageBean.getAttribute("CrmOrgInfoRecords");
pageBean.setRsList(param1Records);
%>
<ec:table 
form="form1"
var="row"
items="pageBean.rsList" csvFileName="CRM_ORG_INFO.csv"
retrieveRowsCallback="process" xlsFileName="CRM_ORG_INFO.xls"
useAjax="true" sortable="true"
doPreload="false" toolbarContent="navigation|pagejump |pagesize|export|extend|status"
width="100%" rowsDisplayed="10"
listWidth="100%" 
height="auto"
>
<ec:row styleClass="odd" ondblclick="viewSubRecordRequest('detail','CRM_ORG_INFO','CrmOrgInfoEditBox','ORG_ID')" onclick="selectRow(this,{ORG_ID:'${row.ORG_ID}'})">
	<ec:column width="50" style="text-align:center" property="_0" title="序号" value="${GLOBALROWCOUNT}" />
	<ec:column width="100" property="ORG_NAME" title="ORG_NAME"   />
	<ec:column width="100" property="ORG_TYPE" title="ORG_TYPE"   />
	<ec:column width="100" property="ORG_INTRODUCTION" title="ORG_INTRODUCTION"   />
	<ec:column width="100" property="ORG_LINKMAN_NAME" title="ORG_LINKMAN_NAME"   />
	<ec:column width="100" property="ORG_EMAIL" title="ORG_EMAIL"   />
	<ec:column width="100" property="ORG_CONTACT_WAY" title="ORG_CONTACT_WAY"   />
	<ec:column width="100" property="ORG_STATE" title="ORG_STATE"   />
	<ec:column width="100" property="ORG_LABELS" title="ORG_LABELS"   />
	<ec:column width="100" property="ORG_ADDRESS" title="ORG_ADDRESS"   />
	<ec:column width="100" property="ORG_WEBSITE" title="ORG_WEBSITE"   />
	<ec:column width="100" property="ORG_CREATER" title="ORG_CREATER"   />
	<ec:column width="100" property="ORG_CREATE_TIME" title="ORG_CREATE_TIME"   />
	<ec:column width="100" property="ORG_UPDATE_TIME" title="ORG_UPDATE_TIME"   />
	<ec:column width="100" property="ORG_CLASSIFICATION" title="ORG_CLASSIFICATION"   />
	<ec:column width="100" property="ORG_VISIT_AGAIN_TIME" title="ORG_VISIT_AGAIN_TIME" cell="date" format="yyyy-MM-dd HH:mm" />
	<ec:column width="100" property="CUST_ID" title="CUST_ID"   />
	<ec:column width="100" property="ORG_SOURCES" title="ORG_SOURCES"   />
</ec:row>
</ec:table>
</div>
</div>
<input type="hidden" name="ORG_ID" id="ORG_ID" value=""/>
<script language="javascript">
setRsIdTag('ORG_ID');
</script>
<%}%>


<input type="hidden" id="currentSubTableId" name="currentSubTableId" value="<%=pageBean.inputValue("currentSubTableId")%>" />
<%if (!"_base".equals(pageBean.inputValue("currentSubTableId"))){%>
<script language="javascript">
$("#Layer0").hide();
</script>
<%}%>
<%}%>
<script language="javascript">
new Tab('tab','tabHeader','Layer',<%=currentSubTableIndex%>);
<%if (!"_base".equals(pageBean.inputValue("currentSubTableId"))){%>
$("#Layer0").hide();
<%}%>
</script>
<input type="hidden" name="actionType" id="actionType" value=""/>
<input type="hidden" name="operaType" id="operaType" value="<%=pageBean.getOperaType()%>"/>
<input type="hidden" id="TASK_ID" name="TASK_ID" value="<%=pageBean.inputValue4DetailOrUpdate("TASK_ID","")%>" />
</div>
</form>
<script language="javascript">
initCalendar('TASK_CREATE_TIME','%Y-%m-%d %H:%M','TASK_CREATE_TIMEPicker');
initCalendar('TASK_FINISH_TIME','%Y-%m-%d %H:%M','TASK_FINISH_TIMEPicker');
datetimeValidators[0].set("yyyy-MM-dd HH:mm").add("TASK_CREATE_TIME");
datetimeValidators[1].set("yyyy-MM-dd HH:mm").add("TASK_FINISH_TIME");
initDetailOpertionImage();
$(function(){
	resetTabHeight(80);
});
</script>
</body>
</html>
<%@include file="/jsp/inc/scripts.inc.jsp"%>
